package edu.wayne.cs.csc4110.hw6.plugins.example.maze;


import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Stroke;

import edu.wayne.cs.csc4110.hw6.framework.Util.Constants;

/**
 * Displays a maze to the user as a GUI component.
 */
class MazeDisplay{


    private static final Stroke WALL_STROKE = new BasicStroke(1);

    /* Color scheme. */
    private static final Color WALL = Color.BLACK;

    private Maze maze;

    /**
     * Display the given maze at the given size.
     * @param view  the maze to be displayed
     */
    public MazeDisplay(final Maze view) {
        super();
        setMaze(view);
    }


    public void draw(final Graphics graphics) {
      
        Graphics2D g = (Graphics2D) graphics;
        double scaleX = Constants.PLUGIN_WIDTH * 1.0 / maze.getWidth();
        double scaleY = Constants.PLUGIN_HEIGHT * 1.0 / maze.getHeight();
        g.scale(scaleX, scaleY);
        g.setStroke(WALL_STROKE);
        for (Cell cell : maze) {
            g.setColor(WALL);
            g.draw(cell.getWalls());
        }
    }

    /**
     * Assign a new maze to this display.
     * @param view the new maze to be displayed
     */
    public void setMaze(final Maze view) {
        maze = view;

    }





}
